package tw.com.hitevision.whiteboard.android.display

import android.view.View
import com.hht.sdk.system.HHTSystemManager

/**
 * @name wcd_floatbar
 * @author Realmo
 * @email   momo.weiye@gmail.com
 * @version 1.0.0
 * @time 2019/1/21 9:37
 * @describe
 */
class RectTouchManager {

    private var hhtSystemManager: HHTSystemManager?= null

    constructor(hhtSystemManager: HHTSystemManager){
        this.hhtSystemManager = hhtSystemManager
    }



    private fun initRectTouch(view: View,topLeftX : Int,topLeftY :Int):Int{
        return initRectTouch(topLeftX,topLeftY,view.width,view.height)
    }

    private fun initRectTouch(topLeftX : Int,topLeftY : Int,width:Int,height:Int):Int{
        return hhtSystemManager!!.initIstDisableRectTouchCMD(RectTouchCommandUtil.getInitSourceDisableRectTouchCMD(topLeftX, topLeftY, width, height))
    }

    private fun updateRectTouch(view : View,id:Int,topLeftX : Int,topLeftY : Int){
        updateRectTouch(id,topLeftX,topLeftY,view.width,view.height)
    }

    private fun updateRectTouch(id:Int,topLeftX : Int,topLeftY : Int,width:Int,height:Int){
        hhtSystemManager!!.updateIstDisableRectTouchCMD(RectTouchCommandUtil.getResetSourceDisableRectTouchCMD(id, topLeftX, topLeftY, width, height))
    }

    fun  cancelRectTouch(id : Int){
        hhtSystemManager?.cancelIstDisableRectTouchCMD(RectTouchCommandUtil.getCancelSourceDisableRectTouchCMD(id))
    }


    fun setRectTouch(view :View ,id:Int,topLeftX : Int,topLeftY : Int):Int{
        return setRectTouch(id, topLeftX, topLeftY, view.width,view.height)
    }

    fun setRectTouch(id:Int,topLeftX : Int,topLeftY : Int,width:Int,height:Int):Int{
        if(id == -1){
            return initRectTouch(topLeftX, topLeftY, width, height)
        }else{
            updateRectTouch(id, topLeftX, topLeftY, width, height)
        }
        return id
    }

    fun setSourceDisableTouch(){
        hhtSystemManager!!.setIstSourceDisableTouchCMD(RectTouchCommandUtil.getSourceDisableTouchCMD())
    }

    fun setSourceEnableTouch(){
        hhtSystemManager!!.setIstSourceEnableTouchCMD(RectTouchCommandUtil.getSourceEnableTouchCMD())
    }




}